package com.example.travelservlet.collectionScenery.service;

import com.example.travelservlet.collectionScenery.repository.CollectionSceneryRepository;
import com.example.travelservlet.entity.CollectionScenery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 30697
 */
@Service
public class CollectionSceneryImpl implements CollectionSceneryService{
    @Autowired
    private CollectionSceneryRepository collectionSceneryRepository;

    @Override
    public CollectionScenery createCollectionScenery(CollectionScenery collectionScenery) {
        return collectionSceneryRepository.save(collectionScenery);
    }



    @Override
    public List<String> findSceneryIdsByCollectionId(String collectionId) {

        List<CollectionScenery> collectionSceneries = collectionSceneryRepository.findCollectionSceneriesByCollectId(collectionId);

        List<String> sceneryIds = new ArrayList<>();
        for (CollectionScenery collectionScenery:collectionSceneries){
            sceneryIds.add(collectionScenery.getSceneryId());
        }
        return sceneryIds;
    }
}
